///**
// * @project：serial-comm
// * @title：SerialRunner.java
// * @description： 项目启动后自动执行run方法
// * @package com.serial.comm.core.runner
// * @author：chentl
// * @date：2020/7/8
// * @copyright: 武汉中天云通数据科技有限责任公司  All rights reserved.
// * @version V1.0
// */
//package com.serial.comm.core.runner;
//
//import com.serial.comm.core.constants.properties.SerialProperties;
//import com.serial.comm.core.exception.*;
//import com.serial.comm.core.exception.enums.ResponseCodeEnum;
//import com.serial.comm.core.utils.SerialUtils;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.boot.CommandLineRunner;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//
//@Slf4j
//@Component
//public class SerialRunner  implements CommandLineRunner {
//
//    @Resource
//    private SerialProperties serialProperties;
//
//    @Override
//    public void run(String... args) {
//        String comName  = serialProperties.getComName();
//        Integer speed  = serialProperties.getSpeed();
//        Integer dataBits  = serialProperties.getDataBits();
//        Integer stopBits  = serialProperties.getStopBits();
//        log.info(">>>>>>准备连接串口，当前使用参数：串口名称：{}， 波特率:{},数据位：{}，停止位：{}", comName, speed, dataBits, stopBits);
//        try {
//            SerialUtils.openPort(comName, speed, dataBits, stopBits);
//        } catch (SerialPortParameterFailure serialPortParameterFailure) {
//            throw new SerialPortParameterFailure(ResponseCodeEnum.SERIAL_PORT_PARAMETER_FAILURE);
//        } catch (NotASerialPort notASerialPort) {
//            throw new NotASerialPort(ResponseCodeEnum.NOT_A_SERIAL_PORT);
//        } catch (NoSuchPort noSuchPort) {
//            throw new NoSuchPort(ResponseCodeEnum.NO_SUCH_PORT);
//        } catch (PortInUse portInUse) {
//            throw new PortInUse(ResponseCodeEnum.PORT_IN_USE);
//        } catch (TooManyListeners tooManyListeners) {
//            throw new TooManyListeners(ResponseCodeEnum.TOO_MANY_LISTENERS);
//        }
//    }
//}
